package com.mengyan.oj.judge.codesandbox;

import com.mengyan.oj.judge.codesandbox.impl.ExampleCodeSandbox;
import com.mengyan.oj.judge.codesandbox.impl.RemoteCodeSandbox;
import com.mengyan.oj.judge.codesandbox.impl.ThirdPartyCodeSandbox;

/**
 * 代码沙箱创建工厂
 */
public class CodeSandboxFactory {
    /**
     * 创建代码沙箱实力
     * 如果没有找到对应的代码沙箱则返回ExampleCodeSandbox
     * @param type
     * @return
     */
    public static CodeSandbox newInstance(String type) {
        return switch (type) {
            case "remote" -> new RemoteCodeSandbox();
            case "thirdParty" -> new ThirdPartyCodeSandbox();
            default -> new ExampleCodeSandbox();
        };
    }
}
